package kata;

import java.util.ArrayList;

public class RomanRoulette {
	private ArrayList<Integer> deathParty = new ArrayList<Integer>();

	int calcSurvivalPosition(int size, int skip) {
		int aimPosition = 0;
		for (int i = 1; i <= size; i++) {
			deathParty.add(i);
		}

		while (moreToKill()) {
			aimPosition = killSoldier(skip, aimPosition);
		}
		
		return deathParty.get(0);
	}

	private int killSoldier(int skip, int aimPosition) {
		aimPosition = (aimPosition + skip - 1) % deathParty.size();
		deathParty.remove(aimPosition);
		return aimPosition;
	}

	private boolean moreToKill() {
		return deathParty.size() > 1;
	}
}
